### Combine predictions Oversight Game

library(tidyverse)

sur_pred <- readRDS("precitions_survey.rds"); sur_pred$Mode <- "Survey"
lab_pred <- readRDS("precitions_lab.rds"); lab_pred$Mode <- "Lab"

pred <- bind_rows(sur_pred, lab_pred)

pred$Rational[pred$Role == "Inspector (Politician)" & pred$xfactor == "High control costs\nLow punishment fee"] <- 0.66
pred$Rational[pred$Role == "Inspector (Politician)" & pred$xfactor == "Low control costs\nHigh punishment fee"] <- 0.33

pred$Role <- ifelse(pred$Role == "Inspector (Politician)",
                    "Inspector\n(control)",
                    "Inspectee\n(high quality)") %>%
  factor(levels = c("Inspector\n(control)",
                    "Inspectee\n(high quality)"))
  
pred_plot <- ggplot(pred) + 
  geom_pointrange(aes(x = xfactor, y = b, color = Mode, ymin = llci, ymax = ulci), 
                  position = position_dodge(width = 0.5)) +
  geom_point(aes(x = xfactor, y = Rational), shape = 4, size = 8) +
  facet_wrap(~ Role, ncol = 1) +
  theme_bw(base_size = 18) +
  xlab("") +
  ylab("Prediction") +
  theme(axis.text.x = element_text(angle = 0, vjust = 1, hjust=0.5)) +
  theme(legend.position = "bottom")

pred_plot

ggsave(pred_plot, 
       file = "predictions_combined.jpeg", 
       width = 10, height = 10, dpi = 666)
ggsave(pred_plot, 
       file = "predictions_combined.pdf", 
       width = 10, height = 10)
